package com.phoenix.fly2.rpc;

import java.util.Map;

import com.google.common.collect.Maps;
import com.shforce.fly2.Model;
import com.shforce.fly2.annotation.Controller;
import com.shforce.fly2.annotation.Path;
import com.shforce.fly2.controller.AbstractController;
import com.shforce.fly2.web.WebException;
import com.shforce.fly2.web.result.Result;
import com.shforce.fly2.web.result.TemplateResult;

@Controller
public class TemplateController extends AbstractController {

	@Path("template1.html")
	public Result template1(){
		Model model =  cycle.getModel();
		model.add("name", "徐翔");

		return view("template1");
	}
	@Path("template2.html")
	public Result template2(){
		Map<String, Object> map = Maps.newHashMap();
		map.put("name", "徐翔12");
		map.put("age", 16);
		Model model =  cycle.getModel();
		model.add("person", map);
		return view("page/template2");
	}
	@Path("test1.json")
	public String call(String msg) throws WebException {
		if(msg.equals("1")){
			throw new  RuntimeException("111");
		}
		if(msg.equals("2")){
			throw new  WebException("222");
		}
		return ">>"+msg;
	}
}
